home *** CD-ROM | disk | FTP | other *** search
- title REGCNV04 -- Convert contents of AX to hex characters.
- page 60,120
-
- name REGCNV04 ; module
-
- comment | Module Specifications
-
- Copyright: None.
-
- Environment: IBM PC, tested under DOS 2.0.
-
- Segmentation: Program segment CODE, public, byte aligned, class ''.
-
- Public symbols and external references: See Symbols section of listing.
-
- Link requirements: None, standalone subroutine.
-
- Program derived from: None.
-
- Original code by: Bob Smith and Tom Puckett, October 1983.
-
- Modifications by: None.
-
-
- Procedure Specifications
-
- Public Procedure REGCNV04 -- Convert value in AX to ASCII characters.
-
- This is a subroutine to format and place in storage four ASCII
- characters giving a hexadecimal representation of the value
- passed in AX.
-
- Assumptions: None.
-
- Linkage: Near call and return.
-
- Arguments: AX contains value to be formatted.
- ES:DI point to destination where result is to be placed.
-
- Effects: None.
-
- Results: Flags and AX destroyed.
- DI incremented by four.
- Four hexadecimal digits formatted as ASCII characters
- placed at ES:DI.
-
- Return conditions: None.
-
- Limitations: None.
-
- |
- page
-
- code segment public byte
- assume cs:code
-
- hextable db '0123456789ABCDEF' ; for XLAT below
-
-
-
- public REGCNV04
- REGCNV04 proc near ; see specifications at head of listing
-
- push bx ; preserve
- push dx
-
- cld ; for STOSB below
- mov dx,ax ; value to be formatted
- mov ah,4 ; four hex digits to convert
- mov bx,offset hextable ; translate table
-
- digitloop:
- rol dx,1 ; one bit at a time to minimize number of clocks
- rol dx,1
- rol dx,1
- rol dx,1
- mov al,dl
- and al,0fh ; mask off what's not wanted
- xlat hextable ; convert AL to ASCII
- stosb ; stuff AL at ES:DI, update DI
- dec ah ; loop counter
- jnz digitloop
-
- pop dx ; restore
- pop bx
- ret
-
- REGCNV04 endp
-
- code ends ; end code segment
-
- end ; end module